home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
comnumb.exe
/
COMPOUN.H
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-01
|
2KB
|
59 lines
//////////////////////////////////////////////////////////////////////
// compoun.h: Compound number class definition.
// Copyright (c) 1992 Azarona Software. All rights reserved.
//////////////////////////////////////////////////////////////////////
#ifndef H_COMPOUND
#define H_COMPOUND
#include "rational.h"
class Compound {
private:
long w; // Whole number part
Rational f; // Fractional part
public:
// Constructors and assignment
Compound();
Compound(long n);
Compound(long n, Rational &r);
Compound(Compound const &c);
Compound &operator=(Compound const &c);
// Helper functions
void Simplify();
void Set(long n, Rational &r);
void Invert();
void Negate();
int IsUndefined() const;
int IsNegative() const;
int IsPositive() const;
int IsZero() const;
// Stream I/O operators
friend istream &operator>>(istream &s, Compound &c);
friend ostream &operator<<(ostream &s, const Compound &c);
// Arithmetic operators that modify their operand
Compound operator++(int); // Postfix
Compound operator--(int); // Postfix
Compound &operator++(); // Prefix
Compound &operator--(); // Prefix
Compound &operator+=(const Compound &r);
Compound &operator-=(const Compound &r);
Compound &operator*=(const Compound &r);
Compound &operator/=(const Compound &r);
// Arithmetic operators resulting in new object
Compound operator-() const;
Compound operator+() const;
friend Compound operator+(const Compound &a, const Compound &b);
friend Compound operator-(const Compound &a, const Compound &b);
friend Compound operator*(const Compound &a, const Compound &b);
friend Compound operator/(const Compound &a, const Compound &b);
// Comparison operators
friend int operator==(const Compound &a, const Compound &b);
friend int operator!=(const Compound &a, const Compound &b);
friend int operator<(const Compound &a, const Compound &b);
friend int operator<=(const Compound &a, const Compound &b);
friend int operator>(const Compound &a, const Compound &b);
friend int operator>=(const Compound &a, const Compound &b);
};
#endif